<?php


abstract class BaseRingtoneXml extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $ringtoneid = 0;


	
	protected $name;


	
	protected $singer;


	
	protected $image;


	
	protected $background;


	
	protected $url;


	
	protected $rbtcode;


	
	protected $rtid;


	
	protected $duration;


	
	protected $ordering;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getRingtoneid()
	{

		return $this->ringtoneid;
	}

	
	public function getName()
	{

		return $this->name;
	}

	
	public function getSinger()
	{

		return $this->singer;
	}

	
	public function getImage()
	{

		return $this->image;
	}

	
	public function getBackground()
	{

		return $this->background;
	}

	
	public function getUrl()
	{

		return $this->url;
	}

	
	public function getRbtcode()
	{

		return $this->rbtcode;
	}

	
	public function getRtid()
	{

		return $this->rtid;
	}

	
	public function getDuration()
	{

		return $this->duration;
	}

	
	public function getOrdering()
	{

		return $this->ordering;
	}

	
	public function setRingtoneid($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->ringtoneid !== $v || $v === 0) {
			$this->ringtoneid = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::RINGTONEID;
		}

	} 
	
	public function setName($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->name !== $v) {
			$this->name = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::NAME;
		}

	} 
	
	public function setSinger($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->singer !== $v) {
			$this->singer = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::SINGER;
		}

	} 
	
	public function setImage($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->image !== $v) {
			$this->image = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::IMAGE;
		}

	} 
	
	public function setBackground($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->background !== $v) {
			$this->background = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::BACKGROUND;
		}

	} 
	
	public function setUrl($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->url !== $v) {
			$this->url = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::URL;
		}

	} 
	
	public function setRbtcode($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->rbtcode !== $v) {
			$this->rbtcode = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::RBTCODE;
		}

	} 
	
	public function setRtid($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->rtid !== $v) {
			$this->rtid = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::RTID;
		}

	} 
	
	public function setDuration($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->duration !== $v) {
			$this->duration = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::DURATION;
		}

	} 
	
	public function setOrdering($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->ordering !== $v) {
			$this->ordering = $v;
			$this->modifiedColumns[] = RingtoneXmlPeer::ORDERING;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->ringtoneid = $rs->getInt($startcol + 0);

			$this->name = $rs->getString($startcol + 1);

			$this->singer = $rs->getString($startcol + 2);

			$this->image = $rs->getString($startcol + 3);

			$this->background = $rs->getString($startcol + 4);

			$this->url = $rs->getString($startcol + 5);

			$this->rbtcode = $rs->getString($startcol + 6);

			$this->rtid = $rs->getInt($startcol + 7);

			$this->duration = $rs->getString($startcol + 8);

			$this->ordering = $rs->getInt($startcol + 9);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 10; 
		} catch (Exception $e) {
			throw new PropelException("Error populating RingtoneXml object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RingtoneXmlPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			RingtoneXmlPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RingtoneXmlPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = RingtoneXmlPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += RingtoneXmlPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = RingtoneXmlPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RingtoneXmlPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getRingtoneid();
				break;
			case 1:
				return $this->getName();
				break;
			case 2:
				return $this->getSinger();
				break;
			case 3:
				return $this->getImage();
				break;
			case 4:
				return $this->getBackground();
				break;
			case 5:
				return $this->getUrl();
				break;
			case 6:
				return $this->getRbtcode();
				break;
			case 7:
				return $this->getRtid();
				break;
			case 8:
				return $this->getDuration();
				break;
			case 9:
				return $this->getOrdering();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RingtoneXmlPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getRingtoneid(),
			$keys[1] => $this->getName(),
			$keys[2] => $this->getSinger(),
			$keys[3] => $this->getImage(),
			$keys[4] => $this->getBackground(),
			$keys[5] => $this->getUrl(),
			$keys[6] => $this->getRbtcode(),
			$keys[7] => $this->getRtid(),
			$keys[8] => $this->getDuration(),
			$keys[9] => $this->getOrdering(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RingtoneXmlPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setRingtoneid($value);
				break;
			case 1:
				$this->setName($value);
				break;
			case 2:
				$this->setSinger($value);
				break;
			case 3:
				$this->setImage($value);
				break;
			case 4:
				$this->setBackground($value);
				break;
			case 5:
				$this->setUrl($value);
				break;
			case 6:
				$this->setRbtcode($value);
				break;
			case 7:
				$this->setRtid($value);
				break;
			case 8:
				$this->setDuration($value);
				break;
			case 9:
				$this->setOrdering($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RingtoneXmlPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setRingtoneid($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setSinger($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setImage($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setBackground($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setUrl($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setRbtcode($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setRtid($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setDuration($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setOrdering($arr[$keys[9]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(RingtoneXmlPeer::DATABASE_NAME);

		if ($this->isColumnModified(RingtoneXmlPeer::RINGTONEID)) $criteria->add(RingtoneXmlPeer::RINGTONEID, $this->ringtoneid);
		if ($this->isColumnModified(RingtoneXmlPeer::NAME)) $criteria->add(RingtoneXmlPeer::NAME, $this->name);
		if ($this->isColumnModified(RingtoneXmlPeer::SINGER)) $criteria->add(RingtoneXmlPeer::SINGER, $this->singer);
		if ($this->isColumnModified(RingtoneXmlPeer::IMAGE)) $criteria->add(RingtoneXmlPeer::IMAGE, $this->image);
		if ($this->isColumnModified(RingtoneXmlPeer::BACKGROUND)) $criteria->add(RingtoneXmlPeer::BACKGROUND, $this->background);
		if ($this->isColumnModified(RingtoneXmlPeer::URL)) $criteria->add(RingtoneXmlPeer::URL, $this->url);
		if ($this->isColumnModified(RingtoneXmlPeer::RBTCODE)) $criteria->add(RingtoneXmlPeer::RBTCODE, $this->rbtcode);
		if ($this->isColumnModified(RingtoneXmlPeer::RTID)) $criteria->add(RingtoneXmlPeer::RTID, $this->rtid);
		if ($this->isColumnModified(RingtoneXmlPeer::DURATION)) $criteria->add(RingtoneXmlPeer::DURATION, $this->duration);
		if ($this->isColumnModified(RingtoneXmlPeer::ORDERING)) $criteria->add(RingtoneXmlPeer::ORDERING, $this->ordering);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(RingtoneXmlPeer::DATABASE_NAME);

		$criteria->add(RingtoneXmlPeer::RINGTONEID, $this->ringtoneid);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getRingtoneid();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setRingtoneid($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setName($this->name);

		$copyObj->setSinger($this->singer);

		$copyObj->setImage($this->image);

		$copyObj->setBackground($this->background);

		$copyObj->setUrl($this->url);

		$copyObj->setRbtcode($this->rbtcode);

		$copyObj->setRtid($this->rtid);

		$copyObj->setDuration($this->duration);

		$copyObj->setOrdering($this->ordering);


		$copyObj->setNew(true);

		$copyObj->setRingtoneid('0'); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new RingtoneXmlPeer();
		}
		return self::$peer;
	}

} 